<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>	
		<script>
		window.onload = function() {
			var obtn = document.getElementById('btn1');
			obtn.onclick = function() {
				//1.创建ajax对象
				if(window.XMLHttpRequest) {
					//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
					var oAjax = new XMLHttpRequest();
				} else {
					// IE6, IE5 浏览器执行代码
					var oAjax = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				//2.连接服务器
				//open(方法，文件名,异步传输)
				oAjax.open('GET', 'aaa.txt?t='+new Date().getTime(), true);

				//3.发送请求
				oAjax.send();

				//4.接收返回
				oAjax.onreadystatechange = function() {
					if(oAjax.readyState == 4) {//读取完成
						if(oAjax.status == 200){ //成功
							alert("成功"+oAjax.responseText);
						}else {
						alert("失败"+oAjax.status);
						}
					} 
				};
			};
		};
		</script>
		<input type="button" id="btn1" value="读取" />
	</body>
</html>
